<?php

namespace App\Http\Controllers\V1\Api;

use App\Http\Controllers\V1\Api\BaseController;
use App\Models\V1\News;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class NewsController extends BaseController
{
    /**
     * 新闻列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request){
        $pageSize=$request->input('pageSize',10);
        $query=News::query();
        $data=$query->paginate($pageSize);
        return ajax_output(200,"成功",$data);
    }

    /**
     * 新闻详情
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function details(Request $request){
        $id=$request->input('id',2);
        $model=new News();
        $data=$model->find($id);
        if(!$data){
            return ajax_output(300,"数据不存在");
        }
        return ajax_output(200,"成功",$data);
    }



}
